package com.zzyl.task;

import com.zzyl.mapper.CustomerReservationMapper;
import com.zzyl.utils.ObjectUtil;
import com.zzyl.vo.ReservationVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Slf4j
@Component
public class AutoCleanExpireReservationTask {
    @Autowired
    CustomerReservationMapper customerReservationMapper;

    /**
     * 定时清理过期预约 每1分和31分 0秒执行
     */
    @Scheduled(cron = "0 1,31 * * * ?")
    public void autoSetExpireTimeReservationTaskStatus() {
        log.info("定时清理过期预约: {}", LocalDateTime.now());
        List<ReservationVo> reservationVos = customerReservationMapper.getExpireTime();
        // 批量更改status
        customerReservationMapper.updateBatch(reservationVos);
    }
}
